package com.building.service.impl;

import com.building.common.R;
import com.building.enums.REnum;
import com.building.service.impl.BaseServiceImpl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.building.entity.EngineeringStage;
import java.util.List;
import com.building.mapper.EngineeringStageMapper;
import com.building.service.EngineeringStageService;
/**
@author yinjiahui
@create 2021-04-07 19:22
*/
@Service
public class EngineeringStageServiceImpl extends BaseServiceImpl<EngineeringStageMapper, EngineeringStage> implements EngineeringStageService{

    @Override
    public int updateBatch(List<EngineeringStage> list) {
        return baseMapper.updateBatch(list);
    }
    @Override
    public int updateBatchSelective(List<EngineeringStage> list) {
        return baseMapper.updateBatchSelective(list);
    }
    @Override
    public int batchInsert(List<EngineeringStage> list) {
        return baseMapper.batchInsert(list);
    }
    @Override
    public int insertOrUpdate(EngineeringStage record) {
        return baseMapper.insertOrUpdate(record);
    }
    @Override
    public int insertOrUpdateSelective(EngineeringStage record) {
        return baseMapper.insertOrUpdateSelective(record);
    }

    /**
     *  查询所有的项目工程阶段
     * @return
     */
    @Override
    public List<EngineeringStage> selectEngineeringStage() {
        return this.engineeringStageMapper.selectList(null);
    }

    /**
     *
     * 根据项目工程阶段id删除
     *
     * @param engineeringStageId
     * @return
     */
    @Override
    public void deleteEngineeringStageByEngineeringStageId(Integer engineeringStageId) {
        this.engineeringStageMapper.deleteById(engineeringStageId);
    }

    /**
     *
     * 新增或修改项目工程阶段
     *
     * @param engineeringStage
     * @return
     */
    @Override
    public R insertOrUpdateEngineeringStage(EngineeringStage engineeringStage) {

        if (engineeringStage.getEngineeringStageId() == null){
            this.engineeringStageMapper.insert(engineeringStage);
            return R.result(REnum.SUCCESS_INSERT);
        }else {
            this.engineeringStageMapper.updateById(engineeringStage);
            return R.result(REnum.SUCCESS_UPDATE);
        }
    }
}
